package hoaitt.vnu.edu;

public class Square implements Expression {
	Expression expression;

	public Square(Expression _expr) {
		this.expression = _expr;
	}

	@Override
	public String toString() {
		return expression.toString() + "^2";
	}

	@Override
	public int evaluate() {

		long result = Long.valueOf(expression.evaluate())* Long.valueOf(expression.evaluate());
		return (result > Integer.MAX_VALUE) ? Integer.MAX_VALUE : (int)result;
	}

}
